//
//  FAITHHttpTool.m
//  FAITH微博-02
//
//  Created by faith939339094 on 16/3/18.
//  Copyright © 2016年 faith939339094. All rights reserved.
//

#import "FAITHHttpTool.h"

@implementation FAITHHttpTool


+(void)get:(NSString *)url params:(NSDictionary *)params success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    //获得请求管理者
    AFHTTPSessionManager *mgr=[AFHTTPSessionManager manager];
//    mgr.responseSerializer = [AFHTTPResponseSerializer serializer];


    [mgr GET:url parameters:params progress:^(NSProgress * _Nonnull downloadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (success) {
            success(responseObject);
        };
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (error) {
          
            failure(error);
        }

    }];
     
     
}

+(void)post:(NSString *)url params:(NSDictionary *)params success:(void (^)(id))success failure:(void (^)(NSError *))failure
{
    AFHTTPSessionManager *mgr=[AFHTTPSessionManager manager];
    

    [mgr POST:url parameters:params progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        if (success) {
            success(responseObject);
        };
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        if (error) {
            failure(error);
        }
    }];
}


@end
